package org.example;

import org.apache.pdfbox.multipdf.Splitter;
import org.apache.pdfbox.pdmodel.PDDocument;

import java.io.File;
import java.io.IOException;
import java.util.List;

public class pdf {
    public void division(Integer start,Integer end,Integer page,String file,String name) throws IOException {
        Splitter splitter = new Splitter();
        // 设置起始页、结束页，每个文件的页数
        splitter.setStartPage(start);
        splitter.setEndPage(end);
        splitter.setSplitAtPage(page);
        //文件地址
        PDDocument source = PDDocument.load(new File(file));
        List<PDDocument> list = splitter.split(source);


        int i = 0;
        for (PDDocument document : list) {
            i++;
            document.save("C:\\other\\" + name + i + ".pdf");
        }

    }
}
